<template>
  <div class="newsList">
    <van-card v-for="item in newslist" :key="item.id" :title="item.title" :thumb="item.img_url" @click="goDetail(item.id)">
      <div slot="price">{{ item.add_time }}</div>
      <div slot="num">点击了{{ item.click }}次</div>
    </van-card>
  </div>
</template>
<script>
export default {
  data: () => ({
    newslist: []
  }),
  created() {
    this.getNewsList()
  },
  methods: {
    async getNewsList() {
      try {
        const {
          data: { message }
        } = await this.Api.getNewsList()
        this.newslist = message
        console.log(message)
      } catch (error) {
        this.$Toast('请求新闻失败')
      }
    },
    goDetail(id) {
      this.$router.push('/home/newsinfo/' + id)
    }
  }
}
</script>
<style lang="less" scoped>
.newsList {
  .van-card__content {
    min-height: 58px;
  }
  .van-card__thumb {
    height: 58px;
  }
  .van-card__price {
    color: red;
  }
  .van-card__num {
    color: #222;
  }
  .van-card__title {
    font-size: 14px;
  }
}
</style>
